package com.web_bloks.widget.client;

import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.ui.AbstractImagePrototype;
import com.google.gwt.user.client.ui.Anchor;
import com.google.gwt.user.client.ui.Image;
import com.web_bloks.system.client.Logger;

/**
 * 
 * @author Jean-Lou Dupont
 *
 */
public class EditPageWidget extends Anchor {

	Image img = null;
	
	String api = null;
	
	public EditPageWidget() {
		super();
		
		final WidgetMessages MSG = (WidgetMessages) GWT.create( WidgetMessages.class );
		
		WidgetImageBundle bundle = (WidgetImageBundle) GWT.create( WidgetImageBundle.class );
		
		AbstractImagePrototype p = null;
		
		this.setTitle( MSG.action_edit_page() );

		p = bundle.edit_page();
		img = p.createImage();	
		
		this.getElement().appendChild(img.getElement());
	}//
	
	public void setBaseApiUrl(String api) {
		this.api = new String(api);
	}//
	
	public void setPageName(String page) {
		if (null==api) {
			Logger.logWarn(getClass()+".setPageName: API URL not set");
			return;
		}
		String href = api.replaceAll("{{page}}", page);
		
		this.setHref(href);
	}//
	
}//END